vim.g.vimtex_view_general_options = "-reuse-instance -forward-search @tex @line @pdf"
  .. ' -inverse-search "'
  .. vim.fn.eval "v:progpath"
  .. " --servername "
  .. vim.fn.eval "v:servername"
  .. ' -c "%l" "%f"'

return {
  "lervag/vimtex",
  ft = "tex",
  -- init = function()
  --   --use init as config
  --   vim.g.vimtex_view_method = "general"
  --   vim.g.vimtex_view_automatic = 0
  --   -- vim.g.vimtex_compiler_latexmk = {'continuous': 0}
  --   vim.g.vimtex_quickfix_open_on_warning = 0
  --   vim.g.vimtex_view_general_viewer = "SumatraPDF"
  --   -- vim.g.vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
  --   --             .. ' -inverse-search "'
  --   --             .. vim.fn.eval("v:progpath")
  --   --             .. ' --servername '
  --   --             .. vim.fn.eval("v:servername")
  --   --             .. ' --remote-send \"^<C-\^>^<C-n^>'
  --   --             .. ':execute ''drop '' .. fnameescape(''\%f'')^<CR^>'
  --   --             .. ':\%l^<CR^>:normal\! zzzv^<CR^>'
  --   --             .. ':call remote_foreground('''
  --   --             .. vim.fn.eval("v:servername")
  --   --             .. ''')^<CR^>^<CR^>\""'
  --   vim.g.vimtex_view_general_options_latexmk = "-reuse-instance"
  --   vim.g.vimtex_compiler_latexmk = {
  --     aux_dir = "",
  --     out_dir = "",
  --     callback = 1,
  --     continuous = 1,
  --     executable = "latexmk",
  --     hooks = {},
  --     options = {
  --       "-verbose",
  --       "-file-line-error",
  --       "-synctex=1",
  --       "-interaction=nonstopmode",
  --     },
  --   }
  --   vim.g.vimtex_compiler_latexmk_engines = {
  --     _ = "-xelatex",
  --   }
  --   vim.g.tex_comment_nospell = 1
  --   vim.g.vimtex_compiler_progname = "nvr"
  --   -- vim.g.vimtex_view_general_options = [[--unique file:@pdf\#src:@line@tex]]
  --   -- vim.g.vimtex_view_general_options_latexmk = "--unique"
  -- end,
  -- config = function()
  --   vim.api.nvim_create_autocmd({ "BufWritePost" }, {
  --     pattern = { "*.tex", "latexmkrc" },
  --     callback = function()
  --       -- print(string.format("event fired: %s", vim.inspect(ev)))
  --     end,
  --   })
  --   local wk = require "which-key"
  --   wk.register({
  --     ["<leader>"] = {
  --       l = { "<LocalLeader>", "local" },
  --     },
  --   }, { mode = "n" })
  -- end,
}
